package com.hsy.springmvc.dao.impl;

import com.hsy.springmvc.dao.IUserDao;
import com.hsy.springmvc.model.User;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by hsy on 2017/12/29.
 */
@Repository
public class UserDaoImpl implements IUserDao {

    @Autowired
    private SessionFactory sessionFactory;

    private Session currentSession() {
        return sessionFactory.getCurrentSession();
    }

    public List list(String querySql, Map<String, Object> map) {
        return null;
    }

    public User get(Class clazz, Long userId) {
        return (User) currentSession().get(clazz, userId);
    }

    public void saveBean(User object) {
        currentSession().save(object);
    }

    public void updateBean(User object) {
        currentSession().update(object);
    }
}
